﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using DARE.Save.DataStructures;

namespace DARE
{
    public class CParticleData: ISaveData
    {
        public Vector3 Position { get; set; }
        public Vector3 Velocities { get; set; }
        public bool IsAlive { get; set; }
        public string ParticleEffectName { get; set; }

        public virtual void FillDataStructure(object p)
        {
            IParticle particle = p as IParticle;
            Position = particle.Position;
            Velocities = particle.Velocities;
            IsAlive = particle.IsAlive;
            ParticleEffectName = CResourceMgr.GetResourceName(particle.ParticleEffect);
        }

        public virtual void FillFromDataStructure(out object p, params object[] paramsData)
        {
            p = CreateParticle();
            IParticle particle = p as IParticle;
            particle.Position = Position;
            particle.Velocities = Velocities;
            particle.IsAlive = IsAlive;
            particle.ParticleEffect = CResourceMgr.Load<Effect>(ParticleEffectName);
        }

        public virtual IParticle CreateParticle()
        {
            return null;
        }
    }
}
